package com.augurit.wf.app.fawen.convert;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.augurit.common.util.lang.DateUtils;
import com.augurit.wf.app.fawen.web.form.OaFawenRegisterForm;
import com.augurit.wf.common.entity.OaFawenRegister;

public class OaFawenRegisterConvertor {
	public static OaFawenRegisterForm convertVoToForm(OaFawenRegister entity) {
		if(entity != null) {
			OaFawenRegisterForm form = new OaFawenRegisterForm();
			form.setId(entity.getId());
			form.setRegisterDate(entity.getRegisterDate());
			form.setDocCode(entity.getDocCode());
			form.setDocTitle(entity.getDocTitle());
			form.setSendTo(entity.getSendTo());
			form.setMemo(entity.getMemo());
            form.setType(entity.getType());
			return form;
		}else
			return null;
	}
	
	public static void convertFormToVo(OaFawenRegisterForm form, OaFawenRegister entity) {
		if(entity != null && form != null) {
			entity.setId(form.getId());
			entity.setRegisterDate(form.getRegisterDate());
			if(form.getDocCode() != null && form.getDocCode().trim().length() > 0)
				entity.setDocCode(form.getDocCode().trim());
			if(form.getDocTitle() != null && form.getDocTitle().trim().length() > 0)
				entity.setDocTitle(form.getDocTitle().trim());
			if(form.getSendTo() != null && form.getSendTo().trim().length() > 0)
				entity.setSendTo(form.getSendTo().trim());
			if(form.getMemo() != null && form.getMemo().trim().length() > 0)
				entity.setMemo(form.getMemo().trim());
            if(form.getType() != null && form.getType().trim().length() > 0)
                entity.setType(form.getType().trim());
		}
	}
	
	public static List<OaFawenRegisterForm> convertVoListToFormList(List<OaFawenRegister> oaFawenRegisterList) {
		if(oaFawenRegisterList != null && oaFawenRegisterList.size() > 0) {
			List<OaFawenRegisterForm> oaFawenRegisterFormList = new ArrayList();
			for(int i=0; i<oaFawenRegisterList.size(); i++) {
				oaFawenRegisterFormList.add(convertVoToForm(oaFawenRegisterList.get(i)));
			}
			return oaFawenRegisterFormList;
		}
		return null;
	}
	
	public static List<OaFawenRegister> convertFormListToVoList(List<OaFawenRegisterForm> oaFawenRegisterFormList) {
		if(oaFawenRegisterFormList != null && oaFawenRegisterFormList.size() > 0) {
			List<OaFawenRegister> oaFawenRegisterList = new ArrayList();
			for(int i=0; i<oaFawenRegisterFormList.size(); i++) {
				OaFawenRegister oaFawenRegister = new OaFawenRegister();
				convertFormToVo(oaFawenRegisterFormList.get(i), oaFawenRegister);
				oaFawenRegisterList.add(oaFawenRegister);
			}
			return oaFawenRegisterList;
		}
		return null;
	}
}